#-*- coding:UTF-8 -*-
"""
Version: v1
Last Modified:
All rights reserved
"""

import Config

def ip2num(ip):
    w,x,y,z=tuple([int(x) for x in ip.split(".")])
    num=16777216*w + 65536*x + 256*y + z
    return num

def getId(num):
    print num
    block=open(Config.BLOCK,"r")
    block.readline()
    block.readline()
    for b in block:
        x=[int(eval(x)) for x in b.split(",")]
        #print x
        if num<x[0]:
            return 0
        if num>=x[0] and num<=x[1]:
            return x[2]

def getLoc(id):
    print id        
    block=open(Config.LOCATION,"r")
    block.readline()
    block.readline()
    for b in block:
        x=b.split(",")
        if int(x[0])==id:
            return x
              
if __name__=="__main__":
    ip=""
    num=ip2num(ip)
    id=getId(num)
    print getLoc(id)
    